package io.starteos.wallet.utils.eos.data.remote.model.types;

import com.google.gson.annotations.Expose;

import io.starteos.wallet.utils.eos.crypto.util.HexUtils;
import io.starteos.wallet.utils.eos.data.remote.model.types.EosType.Writer;

public class EosUndelegatebw implements EosType.Packer {
	@Expose
	private TypeAccountName from;
	@Expose
	private TypeAccountName receiver;
	@Expose
	private TypeAsset unstake_net_quantity;
	@Expose
	private TypeAsset  unstake_cpu_quantity;
	

	public EosUndelegatebw(String from, String receiver, String netAsset, String cpuAsset) {
		this.from = new TypeAccountName(from);
		this.receiver = new TypeAccountName(receiver);
		this.unstake_net_quantity = new TypeAsset(netAsset);
		this.unstake_cpu_quantity = new TypeAsset(cpuAsset);
	}

	public String getActionName() {
		return "undelegatebw";
	}

	@Override
	public void pack(Writer writer) {
		from.pack(writer);
		receiver.pack(writer);
		unstake_net_quantity.pack(writer);
		unstake_cpu_quantity.pack(writer);
	}

	public String getAsHex() {
		EosType.Writer writer = new EosByteWriter(512);
		pack(writer);
		return HexUtils.toHex(writer.toBytes());
	}
}
